﻿<div class="text-center">
    <PMobileDatePicker @bind-Value="_date" Formatter="@CustomFormatter">
        <ActivatorContent>
            <MButton Color="primary" Class="text-capitalize" Text @attributes="@context.Attrs">
                @(_date == default ? "Please select" : _date)
            </MButton>
        </ActivatorContent>
    </PMobileDatePicker>
</div>

@code {

    private DateOnly _date;

    private static string CustomFormatter(DatePrecision type, int val)
    {
        return type switch 
        {
            DatePrecision.Year => $"{val}年",
            DatePrecision.Month => $"{val}月",
            DatePrecision.Day => $"{val}日",
            _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
            };
    }

}
